/*
 * Copyright @ 苏州瑞云信息技术有限公司 All rights reserved.
 */
package work.function;

import java.util.function.Consumer;

/**
 * @author Sakura Shen
 * @description 函数式接口的使用
 * @date 2021/9/6
 */
public class ConsumerTest {
    public static void main(String[] args) {

        Consumer<Integer> consumer = x -> {
            int a = x + 2;
            System.out.println(a);// 12
            System.out.println(a + "_");// 12_
        };
        consumer.accept(10);

        String[] strArr = {"费哥哥,男","欢欢姐,女","娇娇妹,女"};
        printInfo(strArr,(message)->{
            System.out.print("姓名:" + message.split(",")[0] + "。  ");
        },(message)->{
            System.out.println("性别:" + message.split(",")[1] + "。");
        });

    }

    public static void printInfo(String[] strArr, Consumer<String> con1, Consumer<String> con2){
        for (int i = 0; i < strArr.length; i++) {
            con1.andThen(con2).accept(strArr[i]);
        }
    }
}
